<script setup>
import { ref } from 'vue'

const arr = ref([
    { id: 1, name: '张三' },
    { id: 2, name: '李四' },
])


const obj = ref({
    id: 1,
    name: "张三"
})
</script>

<template>
    <!-- v-if 优先级高于v-for -->
    <template v-for="(item, index) in arr" :key="item.id">
        <div v-if="item.id == 2">
            {{ item.name }} --- {{ index }}
        </div>
    </template>
    <div v-for="(item, key) in obj">
        {{ item }} --- {{ key }}
    </div>
    <span v-for="n in 10">{{ n }}</span>
</template>